package utils;

import cn.hutool.core.bean.BeanUtil;
import lombok.Builder;
import lombok.Data;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import utils.transfer.BeanCopy;
import utils.transfer.YQNBeanUtil;

/**
 * @author jiangwz
 * @create 2021/9/16.
 */
public class BeanUtilTest {

    @Test
    public void testHutoolCopy(){
        OrderDO orderDO = OrderDO.builder().id(1).mBlNo("MBL123").build();
        OrderDTO build = OrderDTO.builder().build();
        BeanUtil.copyProperties(orderDO, build);

        System.out.println(build);

    }

    @Test
    public void testSpringBeanUtilCopy(){
        OrderDO orderDO = OrderDO.builder().id(1).mBlNo("MBL123").build();
        OrderDTO build = OrderDTO.builder().build();
        BeanUtils.copyProperties(orderDO, build);
        YQNBeanUtil.copyProperties(orderDO, build);

        System.out.println(build);

    }



    @Data
    @Builder
    static class OrderDO {

        private Integer id;
        private String mBlNo;
    }

    @Data
    @Builder
    static class OrderDTO {

        private Integer id;
        @BeanCopy(value = "mBlNo")
        private String blNo;
    }
}
